/**
 * elancom Corporation copy right 2012 - 2015  
 *   
 * $Header: https://192.168.1.224/svn/elancom/product/elancom-platform/trunk/src/main/java/com/elancom/framework/component/Error.java 1034 2012-07-02 03:09:12Z lanzhouxue $
 * $Id: Error.java 1034 2012-07-02 03:09:12Z lanzhouxue $
 * $Author: lanzhouxue $
 * $Date: 2012-07-02 11:09:12 +0800 (Mon, 02 Jul 2012) $
 * $Revision: 1034 $
 */
package com.elancom.framework.component;

import java.io.Serializable;

/**
 * @author elancom
 * @date Apr 28, 2012
 */
public class Error implements Comparable<Error>, Serializable {
	private static final long serialVersionUID = 4754727419727487042L;

	public static final int ERROR_TYPE_VALIDATE = 0x1;

	public static final int ERROR_TYPE_EXCEPTION = 0x1 << 1;

	public static final int ERROR_TYPE_BUSINESS = 0x1 << 2;

	private String key;

	private String content;

	private int errorCode;

	private int errorType = ERROR_TYPE_VALIDATE;

	private int order;

	public Error() {
		super();
	}

	public Error(String key, String content) {
		super();
		this.key = key;
		this.content = content;
	}

	public Error(String key, String content, int errorCode) {
		super();
		this.key = key;
		this.content = content;
		this.errorCode = errorCode;
	}

	@Override
	public int compareTo(Error o) {
		return o.order - order;
	}

	public String getContent() {
		return content;
	}

	public int getErrorCode() {
		return errorCode;
	}

	public String getKey() {
		return key;
	}

	public int getOrder() {
		return order;
	}

	void setContent(String content) {
		this.content = content;
	}

	void setErrorCode(int errorCode) {
		this.errorCode = errorCode;
	}

	public Error setKey(String key) {
		this.key = key;
		return this;
	}

	public Error setOrder(int order) {
		this.order = order;
		return this;
	}

	@Override
	public String toString() {
		return "[" + key + "," + content + "," + errorType + "," + order + "]";
	}

	/**
	 * @return the errorType
	 */
	public int getErrorType() {
		return errorType;
	}

	/**
	 * @param errorType
	 *            the errorType to set
	 */
	public void setErrorType(int errorType) {
		this.errorType = errorType;
	}
}
